package com.atguigu.guli.etl.map;

import com.atguigu.guli.etl.util.EtlUtil;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * @ClassName Mapper
 * @DeScription Mapper
 * @Author 剧情再美终是戏
 * @Date 2019/11/30 9:31
 * @Version 1.0
 **/
public class GuliMapper extends Mapper<LongWritable, Text, String, NullWritable> {

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {

        // 获取一行的数据
        String val = value.toString();

        //进行数据清洗工具
        String result = EtlUtil.parse(val);
        if (null == result) {
            return;
        }

        // 将合法的数据写出
        context.write(result, NullWritable.get());
    }
}
